<template>
	<view class="pages">
		<view class="userInfo" @click.capture="toUserInfo">
			<cloud-image width="150rpx" height="150rpx" v-if="userInfo.avatar_file&&userInfo.avatar_file.url" :src="userInfo.avatar_file.url"></cloud-image>
			<image v-else class="logo-img" src="@/static/uni-center/defaultAvatarUrl.png"></image>
			<view class="logo-title">
				<text class="uer-name" v-if="hasLogin">{{userInfo.nickname||userInfo.username||userInfo.mobile}}</text>
				<text class="uer-name" v-else>{{$t('mine.notLogged')}}</text>
			</view>
		</view>
		<view class="hot_good">
				<view class="good_list"  >
					<view class="good_item" v-for="(item,index) in list" :key="index"  >
						<!-- <view @click="godetail(item._id)"> -->
						<u-lazy-load  :image="item.url" ></u-lazy-load>
						<view class="price">
							<text>￥{{item.total}}</text>
						</view>
						<view class="name">
							{{item.title}}
						</view>
						<view class="content">
							{{item.content}}
						</view>
						</view>
					</view>
				</view>
		</view>
	</view>
</template>

<script>
	import {
		mapGetters,
		
	} from 'vuex';
	export default {
		computed: {
			...mapGetters({
				userInfo: 'user/info',
				hasLogin: 'user/hasLogin'
			})
			// #ifdef APP-PLUS
			,
			appVersion() {
				return getApp().appVersion
			}
			// #endif
			,
			appConfig() {
				return getApp().globalData.config
			},
			
		},
		onLoad() {
			this.getlist()
		},
		data(){
			return{
				list:[]
			}
		},
		methods:{
			getlist(){
				const db = uniCloud.database()
				db.collection('opendb-mall-goods') 
				  .where({
					  user_id:this.$store.state.user.info._id
				  }) 
				  .get()
				  .then(res => {
				    this.list=res.result.data
					
				  })
			}
			// getList(){
			// 	const db = uniCloud.database() //代码块为cdb
			// 	// 使用uni-clientDB
			// 	db.collection('opendb-news-articles')
			// 	  .where({
			// 	   article_status:0
			// 	  }).get()
			// 	  .then((res)=>{
			// 	   // this.flowList=res.result.data
			// 		console.log(res)
			// 	  }).catch((err)=>{
			// 	    console.log(err.code); // 打印错误码
			// 	        console.log(err.message); // 打印错误内容
			// 	  }) 
			// },
		}
	}
</script>

<style lang="scss">
	.pages{
		background-color: #000000;
	}
	.userInfo {
		width: 750rpx;
		padding: 20rpx;
		padding-top: 50px;
		background-image: url(../../static/uni-center/headers.png);
		flex-direction: column;
		align-items: center;
	}	
	.logo-img {
		width: 150rpx;
		height: 150rpx;
		border-radius: 150rpx;
	}
	.uer-name {
		height: 100rpx;
		line-height: 100rpx;
		font-size: 38rpx;
		color: #FFFFFF;
	}
	.hot_good{
		background:#eee;
		overflow:hidden;
		margin-top:10px;
		}
		.tit{
			height:50px;
			line-height:50px;
			color:#b50e03;
			text-align:center;
			letter-spacing:20px;
			background:#fff;
			margin:7rpx 0;
			}
		
		.good_list{
			display:flex;
			padding :0 15rpx;
			flex-wrap:wrap ;//换行
			justify-content:space-between;//左右间距
			}
			.good_item{
				background:#fff;
				width:355rpx;
				margin: 10rpx 0;
				padding:15rpx;
				box-sizing:border-box;
				}
				image{
					width:80%;
					height:150px;
					display:block;
					margin:auto;
				}
				.price{
					color:#b50e03;
					font-size:36rpx;
					margin:15rpx 0 5rpx 0; //上右下左
					}
					text:nth-child(2){
						color:#ccc;
						font-size:28rpx;
						margin-left:7rpx;
						text-decoration: line-through;
					}
				
				.name{
					font-size:28rpx;
					line-height:50rpx;
					padding-bottom:15rpx;
					padding-top:10rpx;
					font-weight: bold;
				}
			    .content{
					font-size:20rpx;
				}
				.adress{
					font-size:28rpx;line-height:50rpx;
					padding-bottom:15rpx;
					padding-top:10rpx;
				}
		
	.grid-text{
		font-size: 10px;
	}
</style>
